const utils = require('../../utils/util.js')
Component({
  properties: {
    placeholderText: {
      type: String,
      value: '搜索'
    }
  },
  data: {
    showPlaceholder: true,
    inputValue: '',
  },
  methods: {
    inputFocusEvent(){
      this.setData({
        showPlaceholder: false
      })
    },
    inputBlurEvent(event){
      let value = event.detail.value.trim();
      if(value===""){
        this.setData({
          showPlaceholder: true
        })
      }
    },
    inputEvent(event){
      let value = event.detail.value.trim();
        this.setData({
          inputValue: value
        })
    },
    inputConfirmEvent(){
      const value = ""+this.data.inputValue;
      if(value){
        this.setData({
          inputValue: '',
          showPlaceholder: true,
        })
        this.triggerEvent('inputdone',{
          search: value
        })
      }
    }
  }
})